import store from './store'
let jumping = false

export function jumped() {
  jumping = false
}

export default function (url = '', data = {}, type = 'push' ) {
  if (!url) return
  const permissions = ['/pages/serve/record/index']
  if (permissions.includes(url) && !store.state.card.id) url = '/pages/alumni/organization/permissions'
  if (typeof url === 'number') {
    uni.navigateBack({ delta: -url })
    return
  }
  const mode = {
    push: 'navigateTo',
    replace: 'redirectTo',
    tab: 'switchTab',
    launch: 'reLaunch'
  }
  let query = ''
    console.log("data",data)
  for (const key in data) query += `${key}=${data[key]}&`
  console.log("query",query)
  if (query) url = `${url}?${query.slice(0, -1)}`
   console.log("url",url)
  uni[mode[type]]({ url })
}
